<?php

namespace app\common\service\pay;

use app\common\service\pay\alipay\AliPayBase;
use app\common\service\pay\alipay\AliPayWap;
use app\common\service\pay\wechat\H5;
use app\common\service\pay\wechat\WechatBase;
use app\model\CouponOrder;

class PayService
{

    public $couponOrder;


    public function __construct(CouponOrder $couponOrder)
    {
        $this->couponOrder = $couponOrder;

    }


    public function payByCouponOrder(PayInterface $pay)
    {

        $pay->init($this->couponOrder);
        /**
         * @var AliPayWap
         * @var WechatBase
         */
        $res = $pay->pay();

        return $res;

    }


    public function refund(PayInterface $pay)
    {

        $pay->setCouponOrder($this->couponOrder);
        /**
         * @var WechatBase
         * @var AliPayBase
         */
        $res = $pay->refund();

        return $res;


    }
}